/* Copyright (c) 2025 Beijing Semidrive Technology Corporation
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @file  dwmac.h
 * @brief Semidrive. AUTOSAR 4.3.1 MCAL Eth plugins.
 */

#ifndef DWMAC_H
#define DWMAC_H

#ifdef __cplusplus
extern "C" {
#endif

#include "Mcal.h"
#include "Eth_PBCfg.h"

#define MAC_INT_FLG_RXSTSIS     BIT(14)
#define MAC_INT_FLG_TXSTSIS     BIT(13)
#define MAC_INT_FLG_TSIS        BIT(12)

#define MAC_INT_EN_RXSTSIS      BIT(14)
#define MAC_INT_EN_TXSTSIS      BIT(13)
#define MAC_INT_EN_TSIS         BIT(12)


#define MAC_RX_STATUS_RWT       BIT(8)
#define MAC_TX_STATUS_EXCOL     BIT(5)
#define MAC_TX_STATUS_LCOL      BIT(4)
#define MAC_TX_STATUS_EXDEF     BIT(3)
#define MAC_TX_STATUS_TJT       BIT(0)


#define ETH_PHY_INTF_SEL_RGMII      1
#define ETH_PHY_INTF_SEL_RMII       4

#define MTL_QUEUE_SIZE      (1024u*6u)


ISR(eth0_handle);
#if (ETH_MAXCTRLS_SUPPORTED == 2U)
ISR(eth1_handle);
#endif
uint32 rx_indication(uint8 CtrlIdx, uint8 Channel);
void tx_indication(uint8 CtrlIdx, uint8 Channel, boolean irq);
void select_eth_mii_type(uint32 eth_instance, uint32 type);
void dwmac_set_clock_delay(uint32 RegBase, boolean rxDelay, boolean txDelay);

#ifdef __cplusplus
}
#endif

#endif

